package com.hs.shirodemo01.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName TreeSelect
 * @Description 树结构
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TreeSelect {

    private Integer id;
    private String label;
    private List<TreeSelect> children;

    public TreeSelect(TbPermission permission){
        this.id = permission.getId();
        this.label = permission.getName();
        if(permission.getChildren()!= null) {
            this.children = permission.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
        }
    }
}
